/**
 * 
 */
package net.fdukedom.epicurus.domain.entity;

/**
 *
 */
public class Extension {
    /**
     * Extension id.
     */
    private int id;
    
    /**
     * Link to plugin.
     */
    private Plugin plugin; 
    
    /**
     * Link to ExtensionPoint.
     */
    private String className; 

    /**
     * Link to ExtensionPoint.
     */
    private String extensionPointName;
    
    /**
     * Reauired by Hibernate.
     */
    public Extension() {
        
    }

    /**
     * Creates instance out of required parameters
     * @param className name of class that supports this extension
     * @param extensionPointName name of extension point ot be registered in
     * @param plugin plug-in which registeres this extension
     */
    public Extension(String className, String extensionPointName, Plugin plugin) {
        this.className = className;
        this.extensionPointName = extensionPointName;
        this.plugin = plugin;
    }

    /**
     * @return the className
     */
    public String getClassName() {
        return className;
    }

    /**
     * @param className the className to set
     */
    public void setClassName(String className) {
        this.className = className;
    }

    /**
     * @return the extensionPointName
     */
    public String getExtensionPointName() {
        return extensionPointName;
    }

    /**
     * @param extensionPointName the extensionPointName to set
     */
    public void setExtensionPointName(String extensionPointName) {
        this.extensionPointName = extensionPointName;
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the plugin
     */
    public Plugin getPlugin() {
        return plugin;
    }

    /**
     * @param plugin the plugin to set
     */
    public void setPlugin(Plugin plugin) {
        this.plugin = plugin;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        final Extension extension = (Extension) o;

        if (className != null ? !className.equals(extension.className) : extension.className != null) return false;
        if (extensionPointName != null ? !extensionPointName.equals(extension.extensionPointName) : extension.extensionPointName != null) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = (className != null ? className.hashCode() : 0);
        result = 29 * result + (extensionPointName != null ? extensionPointName.hashCode() : 0);
        return result;
    }
}
